#!/usr/bin/php
<?
//require_once "gnc_proc.php";

 class SEND_EMAIL extends Controller {
    function index(){
		echo "hai";
	}
	function send_outbox()
	{	
		$query = "select * from rem_t_outbox where status=0";
		echo $query;
		$result_arr = $this->db->query($query);
		$result = $result_arr->result_array();
		
		foreach($result as $idx => $val)
		{					
			$this->load->library('email');
			
			$disclimer = "\n\n\n====================================\nEmail ini dikirimkan oleh Aplikasi SI Del";
			echo $disclimer;
			$this->email->from($val['from']);
			echo $val['from'];
			$this->email->to($val['to']);
			$this->email->cc($val['cc']);		
			$this->email->subject($val['subjek']);
			$this->email->message($val['body'].$disclimer);
			
			
			//if( $this->email->send() ) {
			    $this->email->send();
				//update status
				$data = array(
				   'dt_kirim' => date("Y-m-d H:i:s"),
				   'status' => 1
				 );
				echo $val['subjek']. "<br>";
				$this->db->where('id', $val['id']);
				$this->db->update('rem_t_outbox', $data);
			//}
		}
	
	}	
	
}
?>